<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html >
<html>
<head>
<%@ include file = "MySQL.jsp" %>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>注册检查页面</title>
</head>
<body>
			
<%out.println("------register_do------"); %>
	<form name = "fm">
		
		<%
			request.setCharacterEncoding("utf-8");
			String register_name = request.getParameter("register_name");
			String register_password = request.getParameter("register_password");
			//out.println(register_password);
			String sql = "select * from mark where name='" + register_name + "'";
			ResultSet rs = stmt.executeQuery(sql);
			if(rs.next()){
				out.println("该用户名已经被使用，请点击返回按钮重新输入,或返回主页面");
			}else if(register_name == ""){
				out.println("用户名不能为空！请点击返回键重新输入,或返回主页面");
			}else if(register_password == ""){
				out.println("密码不能为空！请点击返回键重新输入,或返回主页面");
			}else{
				String insert_sql = "insert into mark(name,password) values('"
						+ register_name + "','" + register_password + "');";
				out.println(insert_sql);
				try {
					stmt.executeUpdate(insert_sql);
				} catch (SQLException e) {
					out.println("错误提示：" + e.getMessage());
				} finally {
					stmt.close();
					conn.close();
				}
				out.println("注册成功!");
			}
		%>
	<br><br><br>
	</form>
	<input type = "button" name = "button1" value = "back" onClick = "back()">
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	<input type = "button" name = "button2" value = "return_homePage" onClick = "return_homePage()">
</body>
</html>
<script>
	function back(){
		document.fm.action = "d2018.3.29_register.jsp";
		document.fm.submit();
		
	}
	function return_homePage(){
		document.fm.action = "d2018.3.29_homePage.jsp";
		document.fm.submit();
	}
</script>